package com.example.Dao;

import com.example.pojo.CateCory;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CateGoryMapper {

    //1.添加文章分类
    @Insert("insert into category(name,asName,create_user,create_time,updata_time)" +
            " values (#{name},#{asName},#{createUser},#{createTime},#{updataTime})")
    void add(CateCory cateCory);

    //2.根据登录用户查询文章列表
    @Select("select id,name,asName,create_user createUser,create_time createTime,updata_time updataTime from category where create_user = #{createId}")
    List<CateCory> list(int createId);

    //3.查询文章详情
    @Select("select id,name,asName,create_user createUser,create_time createTime,updata_time updataTime from category where id = #{id}")
    CateCory selectDetail(Integer id);

    //4.根据传来的数据修改文章
    @Update("update category set name = #{name},asName = #{asName},updata_time = now() where id = #{id}")
    void updata(CateCory cateCory);

    //5.删除文章分类
    @Delete("delete from category where id = #{id}")
    void delete(Integer id);

    // 6.根据创建者id查询分类文章
    @Select("select * from category where create_user = #{createId};")
    List<CateCory> LookC(int createId);
}
